/*
 * Project CHEN Rendering Engine : /shape.hpp
 * Created: 2020-12-16, Last modified:  2021-03-03
 * 
 * This is the default descriptor.
 * 
 * Copyright (C) 2021 Hineven (hineven@pku.edu.cn)
 * 
 * This program is free software: you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
 * 
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 * 
 * You should have received a copy of the GNU General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 */

#ifndef _H_SHAPE
#define _H_SHAPE
#include "heads.hpp"
#include "object.hpp"
#include "optics.hpp"
#include "geometry.hpp"
namespace chen {

class Shape: public Object{
public:
    int flags;
    Bound3 wbnd;
    const Material * material; // shared
    const AreaLight * arealight;
    Shape (const Transform * tr, const Material * m): Object::Object(tr), flags(0), material(m), arealight(nullptr) {}
    virtual bool interact (const Ray & r, SurfInteract * si) const = 0;
    virtual bool mask (const Ray & r) const = 0;
    // Return the one sided area of the shape
    virtual Float area () const = 0; 
    // Uniformly sample the shape (no any side is clearly identified)
    virtual void uniformSample (const Point2 & u, Interact * si, Point2 * uv, Float * pdf) const;
    // Uniformly sample the shape that is possibly visible to the interaction
    // PDF here is defined over shape surface area
    virtual void uniformSampleFrom (const Point2 & u, const Interact & from, Interact * si, Point2 * uv, Float * pdf) const;
    virtual ~Shape () {}
    inline virtual std::string nameit () const {
        return "Default Shape";
    }
};

}
#endif